public class TestDemo1 {
    //方法重载
    public static int Add(int a, int b) {
        return a + b;
    }

    public static double Add(double a, double b) {
        return a + b;
    }

    public static void main1(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(Add(a, b));
    }

    //递归
    public static int fac(int n) {
        if (n == 1) {
            return 1;
        }
        return n * fac(n - 1);
    }

    public static void main2(String[] args) {
        System.out.println(fac(1));
    }

    //打印一个数字的每一位
    public static void print(int n) {
        if (n < 10) {
            System.out.println(n);
        } else {
            print(n / 10);
            System.out.println(n % 10);
        }
    }

    public static void main3(String[] args) {
        print(123);
    }

    public static int sum(int n) {
        if (n == 1) {
            return 1;
        }
        return n + sum(n - 1);
    }

    public static void main(String[] args) {
        System.out.println(2);
    }

}


